home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11497 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  935 b 

  1. Path: gryphon.phoenix.net!usenet
  2. From: brucew@phoenix.net (Bruce Wedding)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Pointers to structures question.
  5. Date: Sun, 24 Mar 1996 18:30:43 GMT
  6. Organization: BranPaul Systems
  7. Message-ID: <4j44g2$6uk@gryphon.phoenix.net>
  8. References: <4j2drs$q3r@dfw-ixnews3.ix.netcom.com>
  9. NNTP-Posting-Host: dial60.phoenix.net
  10. X-Newsreader: Moe's Newsreader    
  11.  
  12. In comp.lang.c
  13. ishky@ix.netcom.com(Andrew Heiz ) wrote:
  14.  
  15. >I have a simple question about using pointers to structures. I am
  16. >imputing data into a structure using:
  17. >
  18. >        gets(struct.element);
  19.  
  20. The first comment is that you should use fgets() instead of
  21. gets()
  22.  
  23. >My question is in how to reference the structure element with a
  24. >pointer. How do I do this?
  25.  
  26.  
  27. Provided that you have a pointer defined and pointing at the
  28. struct, you may use dot notation or the more preferred ->
  29. operator, like this:
  30.  
  31. fgets( struct_ptr->element, MAX_LEN, stdin);
  32.  
  33. Bruce
  34.  
  35.